import { listByParentCode } from '@/api/nongjt/area'

export const AreaMixins = {
  data() {
    return {
      // 省份列表
      mixinsProvinceList: [],
      // 市列表
      mixinsCityList: [],
      // 区县列表
      mixinsAreaList: [],
      //街道列表
      mixinsStreetList: []
    }
  },
  created() {
    this.initProvinceList()
  },
  methods: {
    //初始化省
    initProvinceList() {
      listByParentCode().then(res => {
        this.mixinsProvinceList = res.data
      })
    },
    //选择省改变
    mixinsProvinceChange(parentCode) {
      console.log(parentCode)
      listByParentCode({ parentCode: parentCode }).then(res => {
        this.mixinsCityList = res.data
      })
    },
    //选择市改变
    mixinsCityChange(parentCode) {
      listByParentCode({ parentCode: parentCode }).then(res => {
        this.mixinsAreaList = res.data
      })
    },
    //选择区改变
    mixinsAreaChange(parentCode) {
      listByParentCode({ parentCode: parentCode }).then(res => {
        this.mixinsStreetList = res.data
      })
    },
    //重置
    mixinsResetAreaList() {
      this.mixinsCityList = []
      this.mixinsAreaList = []
      this.mixinsStreetList = []
    }
  }
}

